package main

import "fmt"

func getInfo(arr []int) {
	fmt.Printf("长度：%d ，容器：%d，数组：%v\n", len(arr), cap(arr), arr)
}

func sum(array []int) int {
	fmt.Printf("数组:%v	", array)
	var sum int = 0
	for _, val := range array {
		sum += val
	}
	return sum
}

func main() {
	var a = []int{1, 2, 3, 4, 5}
	var b = a[0:3]
	var c = [...]int{1, 2, 3, 4, 5, 6, 7, 8}
	var d = c[0:2]
	getInfo(b)
	getInfo(d)
	fmt.Printf("sum:%d\n", sum(b))
	fmt.Printf("sum:%d\n", sum(d))
}
